package com.jh.gmtv.ui.my;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jh.gmtv.R;
import com.jh.gmtv.bean.ListBean;

import java.util.List;

/**
 * Created by Mr.J on 2016/10/19.
 */

public class MyListAdapter extends BaseAdapter {
    private List<ListBean> mData;
    private LayoutInflater mInflater;
    private Context mContext;

    public MyListAdapter (List<ListBean> data,Context context){
        this.mData = data;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return mData != null?mData.size():0;
    }

    @Override
    public Object getItem(int position) {
        return mData != null?mData.get(position):0;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.my_list_item,parent,false);
        ImageView myListIv1 = (ImageView) convertView.findViewById(R.id.my_list_iv1);
        ImageView myListIv2 = (ImageView) convertView.findViewById(R.id.my_list_iv2);
        TextView myListTxt = (TextView) convertView.findViewById(R.id.my_list_txt);
        myListIv1.setBackgroundResource(mData.get(position).getIcon());
        myListIv2.setBackgroundResource(mData.get(position).getImg());
        myListTxt.setText(mData.get(position).getTextName());

        return convertView;
    }
}
